import javax.sound.midi.*;

public class MusicTest1 {
	public static void main(String[] args) {
		try {
			Sequencer sequencer = MidiSystem.getSequencer();
			sequencer.open();
			Sequence sequence = new Sequence(Sequence.PPQ, 4);
			Track track = sequence.createTrack();
			
			ShortMessage a = new ShortMessage();
			a.setMessage(144, 1, 100, 100);
			MidiEvent noteOn = new MidiEvent(a, 1);
			track.add(noteOn);
			
			ShortMessage b = new ShortMessage();
			a.setMessage(128, 1, 44, 100);
			MidiEvent noteOff = new MidiEvent(b, 16);
			track.add(noteOff);
			
			sequencer.setSequence(sequence);
			sequencer.start();
			
		} catch (MidiUnavailableException e) {
			e.printStackTrace();
			System.err.println(e.getMessage());
		} catch (InvalidMidiDataException e) {
			e.printStackTrace();
			System.err.println(e.getMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("sequencer obtained");
	}
}
